package com.sayice.robotconflict.game.object.property;

/**
 * 可见坐标
 *
 * @author shubing
 */
public class VolatileCoord implements Coord {
    /**
     * x坐标
     */
    protected volatile double x;
    
    /**
     * y坐标
     */
    protected volatile double y;
    
    public VolatileCoord(double x, double y) {
        this.x = x;
        this.y = y;
    }
    
    public VolatileCoord(Coord coord) {
        this.x = coord.getX();
        this.y = coord.getY();
    }
    
    @Override
    public double getX() {
        return x;
    }
    
    @Override
    public double getY() {
        return y;
    }
    
    @Override
    public void setX(double x) {
        this.x = x;
    }
    
    @Override
    public void setY(double y) {
        this.y = y;
    }
    
    @Override
    public void set(double x, double y) {
        this.x = x;
        this.y = y;
    }
    
    /**
     * {@inheritDoc}
     * <p>非原子性
     */
    @Override
    @SuppressWarnings("all")
    public void addX(double value) {
        x += value;
    }
    
    /**
     * {@inheritDoc}
     * <p>非原子性
     */
    @Override
    @SuppressWarnings("all")
    public void addY(double value) {
        y += value;
    }
}